package com.msti.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.msti.entity.Employee;
import com.msti.entity.Student;
import com.msti.service.EmployeeMgtDAO;
import com.msti.service.EmployeeMgtDAOImpl;
import com.msti.utility.Utility;

/**
 * Servlet implementation class AddEmployee
 */
public class AddEmployee extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AddEmployee() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Employee employee = new Employee();
		employee.setName(request.getParameter("name"));
		employee.setNicno(request.getParameter("NICNO"));
		employee.setPhone(request.getParameter("phone"));
		employee.setCenter(request.getParameter("center"));
		employee.setRole(request.getParameter("role"));
		employee.setUsername(request.getParameter("uName"));
		employee.setPassword(request.getParameter("pWord"));
		EmployeeMgtDAO employeeMgtDAO = new EmployeeMgtDAOImpl();
		employeeMgtDAO.insertEmployee(employee);
		response.sendRedirect("adminPage.jsp");
	}

}
